// 登录界面
import global from './../global'

cc.Class({
    extends: cc.Component,

    properties: {
       
    },

    start () {
        // cc.loader.loadResArray(['config/creater_room_config'], (err, data)=>{
        //     if(err){
        //         cc.log('creater room config err = ' + err);
        //     } else {
        //         cc.log('creater room config = ' + JSON.stringify(data));
        //     }
        // });
        let gameConfig = defines.gameConfig;
        let resList = [];
        for (let i in gameConfig){
            resList.push(gameConfig[i]);
        }

        global.AdministrationData.ResManager.loadList(resList, ()=>{
            global.Socket.init();
        });
    },

    onLognBtnClick : function(event, custonData) {
        global.Socket.login(
            global.AdministrationData.PlayerData.uniqueID,
            global.AdministrationData.PlayerData.nickName,
            global.AdministrationData.PlayerData.avatarUrl, (err, data)=>{
                if(err){
                    cc.log('login error : ' + err);
                } else {
                    // cc.log('login data : ' + JSON.stringify(data));
                    global.AdministrationData.PlayerData.loginSuccess(data);
                    cc.director.loadScene('HomeScene');
                }
            }
        );
    }
});
